//
//  RXXKPlayViewController.m
//  RXXKVideo
//
//  Created by 星仔 on 2019/3/17.
//  Copyright © 2019年 rxx. All rights reserved.
//

#import "RXXKPlayViewController.h"
#import "RXXKVideoView.h"
#import "Masonry.h"
#import "const.h"
#import "UIImage+RXCategory.h"
@interface RXXKPlayViewController ()
@property (nonatomic, strong) UIButton  *backBtn;
@property (nonatomic, strong) UIButton  *searchBtn;

@property (nonatomic, strong) UIView    *titleView;
@property (nonatomic, strong) UIButton  *recBtn;
@property (nonatomic, strong) UIButton  *cityBtn;

@end

@implementation RXXKPlayViewController
#pragma mark - ♻️life cycle
- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor blackColor];
    self.navigationController.navigationBar.hidden = YES;
    [self.view addSubview:self.videoView];
    
    //解决self.videoView的高度为不是屏幕高度问题
//    [self.videoView mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.edges.equalTo(self.view);
//    }];
    self.videoView.frame = self.view.bounds;
    [self.view addSubview:self.searchBtn];
    
    [self.view addSubview:self.titleView];
    [self.titleView addSubview:self.recBtn];
    [self.titleView addSubview:self.cityBtn];
    
    [self.searchBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).offset(15.0f);
        make.top.equalTo(self.view).offset(RX_SAVEAREA_TOP + 20.0f);
    }];
    
    [self.titleView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view);
        make.centerY.equalTo(self.searchBtn);
        make.width.mas_equalTo(160.0f);
        make.height.mas_equalTo(30.0f);
    }];
    
    [self.recBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.titleView);
        make.centerX.equalTo(self.titleView).offset(-24);
    }];
    
    [self.cityBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.titleView);
        make.centerX.equalTo(self.titleView).offset(24);
    }];
}

#pragma mark - 🔒private
#pragma mark - 🚪public
#pragma mark - 🍐delegate
#pragma mark - 🔄overwrite
#pragma mark - ☎️notification
#pragma mark - 🎬event response
- (void)itemClick:(UIButton *)sender{
    if (sender == self.recBtn) {
        self.recBtn.titleLabel.font = [UIFont boldSystemFontOfSize:18.0f];
        self.cityBtn.titleLabel.font = [UIFont systemFontOfSize:16.0f];
        [self.recBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [self.cityBtn setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
    }else if (sender == self.cityBtn){
        self.cityBtn.titleLabel.font = [UIFont boldSystemFontOfSize:18.0f];
        self.recBtn.titleLabel.font = [UIFont systemFontOfSize:16.0f];
        [self.cityBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [self.recBtn setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
    }
}
- (void)searchClick:(UIButton *)sender{
    
}
#pragma mark - ☸getter and setter
- (RXXKVideoView *)videoView{
    if (!_videoView) {
        _videoView = [[RXXKVideoView alloc] initWithVC:self isPushed:NO];
    }
    return _videoView;
}

- (UIButton *)searchBtn {
    if (!_searchBtn) {
        _searchBtn = [UIButton new];
        [_searchBtn setImage:[[UIImage imageNamed:@"nav_search"] changeImageWithColor:[UIColor whiteColor]] forState:UIControlStateNormal];
        [_searchBtn addTarget:self action:@selector(searchClick:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _searchBtn;
}

- (UIView *)titleView {
    if (!_titleView) {
        _titleView = [UIView new];
    }
    return _titleView;
}

- (UIButton *)recBtn {
    if (!_recBtn) {
        _recBtn = [UIButton new];
        [_recBtn setTitle:@"推荐" forState:UIControlStateNormal];
        [_recBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        _recBtn.titleLabel.font = [UIFont boldSystemFontOfSize:18.0f];
        [_recBtn addTarget:self action:@selector(itemClick:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _recBtn;
}

- (UIButton *)cityBtn {
    if (!_cityBtn) {
        _cityBtn = [UIButton new];
        [_cityBtn setTitle:@"同城" forState:UIControlStateNormal];
        [_cityBtn setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
        _cityBtn.titleLabel.font = [UIFont systemFontOfSize:16.0f];
        [_cityBtn addTarget:self action:@selector(itemClick:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _cityBtn;
}

@end
